package router

import (
	"github.com/gin-gonic/gin"
	"LazyPig/apis"
	"net/http"
)

func InitRouter() http.Handler {
	router := gin.Default()
	router.Use(Cors())
	router.Static("/statics","./statics")
	//router.LoadHTMLFiles("view/404/index.html")
	//router.NoRoute(NotFound())
	//router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
	router.GET("/login", apis.Login)
	router.GET("/web/login", apis.LoginWeb)
	//router.GET("/refreshToken", apis.RefreshToken)
	//router.GET("/sendSmsCode", apis.SendSmsCode)

	router.Use(Authorize())
	router.GET("/getUserInfo", apis.GetUserInfo)
	router.GET("/getPersonnel", apis.GetPersonnel)
	router.POST("/rule/add", apis.NewRule)
	router.GET("/rule/list", apis.GetRuleList)
	router.GET("/rule/detail", apis.GetRule)
	router.GET("/rule/came", apis.GetCame)
	router.GET("/rule/delete", apis.Delete)
	router.GET("/attendance/start", apis.Attendance)
	router.GET("/attendance/adList", apis.GetAbList)
	router.GET("/attendance/atList", apis.GetAtList)
	router.GET("/password", apis.Password)

	// 授权组
	authorized := router.Group("/")
	authorized.Use(Authorize())
	{

	}

	return router
}

func NotFound() gin.HandlerFunc {
	return func(c *gin.Context) {
		c.HTML(200,"index.html", nil)
	}
}
